﻿namespace MicroCloud.Utils
{
    /// <summary>
    /// 业务操作结果
    /// </summary>
    public class OperationResult : OperationResult<object>
    {
        #region "构造函数"
        #region "初始化一个业务操作结果的新实例"
        /// <summary>
        /// 初始化一个业务操作结果 <see cref="OperationResult"/> 的新实例
        /// </summary>
        public OperationResult()
            : this(OperationResultType.Success)
        { }
        #endregion
        #region "初始化一个业务操作结果的新实例"
        /// <summary>
        /// 初始化一个业务操作结果 <see cref="OperationResult"/> 的新实例
        /// </summary>
        /// <param name="resultType">业务操作结果</param>
        public OperationResult(OperationResultType resultType)
            : this(resultType, null, null)
        { }
        #endregion
        #region "初始化一个业务操作结果的新实例"
        /// <summary>
        /// 初始化一个业务操作结果 <see cref="OperationResult"/> 的新实例
        /// </summary>
        /// <param name="resultType">业务操作结果</param>
        /// <param name="message">业务操作返回消息</param>
        public OperationResult(OperationResultType resultType, string message)
            : this(resultType, message, null)
        { }
        #endregion
        #region "初始化一个业务操作结果的新实例"
        /// <summary>
        /// 初始化一个业务操作结果 <see cref="OperationResult"/> 的新实例
        /// </summary>
        /// <param name="resultType">业务操作结果</param>
        /// <param name="message">业务操作结果消息</param>
        /// <param name="data">业务操作结果数据</param>
        public OperationResult(OperationResultType resultType, string message, object data)
            : base(resultType, message, data)
        { }
        #endregion

        #endregion

        #region "方法"
        #region "将 <see cref="OperationResult{TData}"/> 转换为 <see cref="OperationResult"/>"
        /// <summary>
        /// 将 <see cref="OperationResult{TData}"/> 转换为 <see cref="OperationResult"/>
        /// </summary>
        /// <returns></returns>
        public OperationResult<T> ToOperationResult<T>()
        {
            T data = default;
            if (Data is T variable)
            {
                data = variable;
            }
            return new OperationResult<T>() { ResultType = ResultType, Message = Message, Data = data };
        }
        #endregion

        #endregion

        #region "静态方法"
        // 200
        #region "成功的操作结果"
        /// <summary>
        /// 成功的操作结果
        /// </summary>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult Success(string message = "")
        {
            return Success(null, message);
        }
        #endregion
        #region "成功的操作结果"
        /// <summary>
        /// 成功的操作结果
        /// </summary>
        /// <param name="data">业务操作结果数据</param>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult Success(object data, string message = "")
        {
            var resultType = OperationResultType.Success;
            message = message.IsMissing() ? I18N.T(resultType.ToDescription()) : message;
            return new OperationResult() { ResultType = resultType, Message = message, Data = data };
        }
        #endregion
        #region "指定类型的成功操作结果"
        /// <summary>
        /// 指定类型的成功操作结果
        /// </summary>
        /// <typeparam name="T">操作结果数据类型</typeparam>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult<T> Success<T>(string message = null)
        {
            return Success<T>(default, message);
        }
        #endregion
        #region "指定类型的成功操作结果"
        /// <summary>
        /// 指定类型的成功操作结果
        /// </summary>
        /// <typeparam name="T">操作结果数据类型</typeparam>
        /// <param name="data">业务操作结果数据</param>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult<T> Success<T>(T data, string message = null)
        {
            var resultType = OperationResultType.Success;
            message = message.IsMissing() ? I18N.T(resultType.ToDescription()) : message;
            return new OperationResult<T>() { ResultType = resultType, Message = message, Data = data };
        }
        #endregion
        // 400
        #region "错误的操作结果"
        /// <summary>
        /// 错误的操作结果
        /// </summary>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult Error(string message = "")
        {
            return Error(null, message);
        }
        #endregion
        #region "错误的操作结果"
        /// <summary>
        /// 错误的操作结果
        /// </summary>
        /// <param name="data">业务操作结果数据</param>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult Error(object data, string message = "")
        {
            var resultType = OperationResultType.Error;
            message = message.IsMissing() ? I18N.T(resultType.ToDescription()) : message;
            return new OperationResult() { ResultType = resultType, Message = message, Data = data };
        }
        #endregion
        #region "指定类型的错误操作结果"
        /// <summary>
        /// 指定类型的错误操作结果
        /// </summary>
        /// <typeparam name="T">操作结果数据类型</typeparam>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult<T> Error<T>(string message = null)
        {
            return Error<T>(default, message);
        }
        #endregion
        #region "指定类型的错误操作结果"
        /// <summary>
        /// 指定类型的错误操作结果
        /// </summary>
        /// <typeparam name="T">操作结果数据类型</typeparam>
        /// <param name="data">业务操作结果数据</param>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult<T> Error<T>(T data, string message = null)
        {
            var resultType = OperationResultType.Error;
            message = message.IsMissing() ? I18N.T(resultType.ToDescription()) : message;
            return new OperationResult<T>() { ResultType = resultType, Message = message, Data = data };
        }
        #endregion
        // 401
        #region "未经授权的操作结果"
        /// <summary>
        /// 未经授权的操作结果
        /// </summary>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult Unauthorized(string message = "")
        {
            return Unauthorized(null, message);
        }
        #endregion
        #region "未经授权的操作结果"
        /// <summary>
        /// 未经授权的操作结果
        /// </summary>
        /// <param name="data">业务操作结果数据</param>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult Unauthorized(object data, string message = "")
        {
            var resultType = OperationResultType.Unauthorized;
            message = message.IsMissing() ? I18N.T(resultType.ToDescription()) : message;
            return new OperationResult() { ResultType = resultType, Message = message, Data = data };
        }
        #endregion
        #region "指定类型的未经授权操作结果"
        /// <summary>
        /// 指定类型的未经授权操作结果
        /// </summary>
        /// <typeparam name="T">操作结果数据类型</typeparam>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult<T> Unauthorized<T>(string message = null)
        {
            return Unauthorized<T>(default, message);
        }
        #endregion
        #region "指定类型的未经授权操作结果"
        /// <summary>
        /// 指定类型的未经授权操作结果
        /// </summary>
        /// <typeparam name="T">操作结果数据类型</typeparam>
        /// <param name="data">业务操作结果数据</param>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult<T> Unauthorized<T>(T data, string message = null)
        {
            var resultType = OperationResultType.Unauthorized;
            message = message.IsMissing() ? I18N.T(resultType.ToDescription()) : message;
            return new OperationResult<T>() { ResultType = resultType, Message = message, Data = data };
        }
        #endregion
        // 403
        #region "被禁止的操作结果"
        /// <summary>
        /// 被禁止的操作结果
        /// </summary>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult Forbidden(string message = "")
        {
            return Forbidden(null, message);
        }
        #endregion
        #region "被禁止的操作结果"
        /// <summary>
        /// 被禁止的操作结果
        /// </summary>
        /// <param name="data">业务操作结果数据</param>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult Forbidden(object data, string message = "")
        {
            var resultType = OperationResultType.Forbidden;
            message = message.IsMissing() ? I18N.T(resultType.ToDescription()) : message;
            return new OperationResult() { ResultType = resultType, Message = message, Data = data };
        }
        #endregion
        #region "指定类型的被禁止操作结果"
        /// <summary>
        /// 指定类型的被禁止操作结果
        /// </summary>
        /// <typeparam name="T">操作结果数据类型</typeparam>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult<T> Forbidden<T>(string message = null)
        {
            return Forbidden<T>(default, message);
        }
        #endregion
        #region "指定类型的被禁止操作结果"
        /// <summary>
        /// 指定类型的被禁止操作结果
        /// </summary>
        /// <typeparam name="T">操作结果数据类型</typeparam>
        /// <param name="data">业务操作结果数据</param>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult<T> Forbidden<T>(T data, string message = null)
        {
            var resultType = OperationResultType.Forbidden;
            message = message.IsMissing() ? I18N.T(resultType.ToDescription()) : message;
            return new OperationResult<T>() { ResultType = resultType, Message = message, Data = data };
        }
        #endregion
        // 404
        #region "未找到的操作结果"
        /// <summary>
        /// 未找到的操作结果
        /// </summary>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult NotFound(string message = "")
        {
            return NotFound(null, message);
        }
        #endregion
        #region "未找到的操作结果"
        /// <summary>
        /// 未找到的操作结果
        /// </summary>
        /// <param name="data">业务操作结果数据</param>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult NotFound(object data, string message = "")
        {
            var resultType = OperationResultType.NotFound;
            message = message.IsMissing() ? I18N.T(resultType.ToDescription()) : message;
            return new OperationResult() { ResultType = resultType, Message = message, Data = data };
        }
        #endregion
        #region "指定类型的未找到操作结果"
        /// <summary>
        /// 指定类型的未找到操作结果
        /// </summary>
        /// <typeparam name="T">操作结果数据类型</typeparam>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult<T> NotFound<T>(string message = null)
        {
            return NotFound<T>(default, message);
        }
        #endregion
        #region "指定类型的未找到操作结果"
        /// <summary>
        /// 指定类型的未找到操作结果
        /// </summary>
        /// <typeparam name="T">操作结果数据类型</typeparam>
        /// <param name="data">业务操作结果数据</param>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult<T> NotFound<T>(T data, string message = null)
        {
            var resultType = OperationResultType.NotFound;
            message = message.IsMissing() ? I18N.T(resultType.ToDescription()) : message;
            return new OperationResult<T>() { ResultType = resultType, Message = message, Data = data };
        }
        #endregion
        // 405
        #region "不被允许的操作结果"
        /// <summary>
        /// 不被允许的操作结果
        /// </summary>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult NotAllowed(string message = "")
        {
            return NotAllowed(null, message);
        }
        #endregion
        #region "不被允许的操作结果"
        /// <summary>
        /// 不被允许的操作结果
        /// </summary>
        /// <param name="data">业务操作结果数据</param>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult NotAllowed(object data, string message = "")
        {
            var resultType = OperationResultType.NotAllowed;
            message = message.IsMissing() ? I18N.T(resultType.ToDescription()) : message;
            return new OperationResult() { ResultType = resultType, Message = message, Data = data };
        }
        #endregion
        #region "指定类型的不被允许操作结果"
        /// <summary>
        /// 指定类型的不被允许操作结果
        /// </summary>
        /// <typeparam name="T">操作结果数据类型</typeparam>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult<T> NotAllowed<T>(string message = null)
        {
            return NotAllowed<T>(default, message);
        }
        #endregion
        #region "指定类型的不被允许操作结果"
        /// <summary>
        /// 指定类型的不被允许操作结果
        /// </summary>
        /// <typeparam name="T">操作结果数据类型</typeparam>
        /// <param name="data">业务操作结果数据</param>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult<T> NotAllowed<T>(T data, string message = null)
        {
            var resultType = OperationResultType.NotAllowed;
            message = message.IsMissing() ? I18N.T(resultType.ToDescription()) : message;
            return new OperationResult<T>() { ResultType = resultType, Message = message, Data = data };
        }
        #endregion
        // 415
        #region "不被支持的操作结果"
        /// <summary>
        /// 不被支持的操作结果
        /// </summary>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult Unsupported(string message = "")
        {
            return Unsupported(null, message);
        }
        #endregion
        #region "不被支持的操作结果"
        /// <summary>
        /// 不被支持的操作结果
        /// </summary>
        /// <param name="data">业务操作结果数据</param>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult Unsupported(object data, string message = "")
        {
            var resultType = OperationResultType.Unsupported;
            message = message.IsMissing() ? I18N.T(resultType.ToDescription()) : message;
            return new OperationResult() { ResultType = resultType, Message = message, Data = data };
        }
        #endregion
        #region "指定类型的不被支持操作结果"
        /// <summary>
        /// 指定类型的不被支持操作结果
        /// </summary>
        /// <typeparam name="T">操作结果数据类型</typeparam>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult<T> Unsupported<T>(string message = null)
        {
            return Unsupported<T>(default, message);
        }
        #endregion
        #region "指定类型的不被支持操作结果"
        /// <summary>
        /// 指定类型的不被支持操作结果
        /// </summary>
        /// <typeparam name="T">操作结果数据类型</typeparam>
        /// <param name="data">业务操作结果数据</param>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult<T> Unsupported<T>(T data, string message = null)
        {
            var resultType = OperationResultType.Unsupported;
            message = message.IsMissing() ? I18N.T(resultType.ToDescription()) : message;
            return new OperationResult<T>() { ResultType = resultType, Message = message, Data = data };
        }
        #endregion
        // 423
        #region "被锁定的操作结果"
        /// <summary>
        /// 被锁定的操作结果
        /// </summary>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult Locked(string message = "")
        {
            return Locked(null, message);
        }
        #endregion
        #region "被锁定的操作结果"
        /// <summary>
        /// 被锁定的操作结果
        /// </summary>
        /// <param name="data">业务操作结果数据</param>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult Locked(object data, string message = "")
        {
            var resultType = OperationResultType.Locked;
            message = message.IsMissing() ? I18N.T(resultType.ToDescription()) : message;
            return new OperationResult() { ResultType = resultType, Message = message, Data = data };
        }
        #endregion
        #region "指定类型的被锁定操作结果"
        /// <summary>
        /// 指定类型的被锁定操作结果
        /// </summary>
        /// <typeparam name="T">操作结果数据类型</typeparam>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult<T> Locked<T>(string message = null)
        {
            return Locked<T>(default, message);
        }
        #endregion
        #region "指定类型的被锁定操作结果"
        /// <summary>
        /// 指定类型的被锁定操作结果
        /// </summary>
        /// <typeparam name="T">操作结果数据类型</typeparam>
        /// <param name="data">业务操作结果数据</param>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult<T> Locked<T>(T data, string message = null)
        {
            var resultType = OperationResultType.Locked;
            message = message.IsMissing() ? I18N.T(resultType.ToDescription()) : message;
            return new OperationResult<T>() { ResultType = resultType, Message = message, Data = data };
        }
        #endregion
        // 500
        #region "内部错误的操作结果"
        /// <summary>
        /// 内部错误的操作结果
        /// </summary>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult InternalError(string message = "")
        {
            return InternalError(null, message);
        }
        #endregion
        #region "内部错误的操作结果"
        /// <summary>
        /// 内部错误的操作结果
        /// </summary>
        /// <param name="data">业务操作结果数据</param>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult InternalError(object data, string message = "")
        {
            var resultType = OperationResultType.InternalError;
            message = message.IsMissing() ? I18N.T(resultType.ToDescription()) : message;
            return new OperationResult() { ResultType = resultType, Message = message, Data = data };
        }
        #endregion
        #region "指定类型的内部错误操作结果"
        /// <summary>
        /// 指定类型的内部错误操作结果
        /// </summary>
        /// <typeparam name="T">操作结果数据类型</typeparam>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult<T> InternalError<T>(string message = null)
        {
            return InternalError<T>(default, message);
        }
        #endregion
        #region "指定类型的内部错误操作结果"
        /// <summary>
        /// 指定类型的内部错误操作结果
        /// </summary>
        /// <typeparam name="T">操作结果数据类型</typeparam>
        /// <param name="data">业务操作结果数据</param>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult<T> InternalError<T>(T data, string message = null)
        {
            var resultType = OperationResultType.InternalError;
            message = message.IsMissing() ? I18N.T(resultType.ToDescription()) : message;
            return new OperationResult<T>() { ResultType = resultType, Message = message, Data = data };
        }
        #endregion
        // 501
        #region "未实现的操作结果"
        /// <summary>
        /// 未实现的操作结果
        /// </summary>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult NotImplemented(string message = "")
        {
            return NotImplemented(null, message);
        }
        #endregion
        #region "未实现的操作结果"
        /// <summary>
        /// 未实现的操作结果
        /// </summary>
        /// <param name="data">业务操作结果数据</param>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult NotImplemented(object data, string message = "")
        {
            var resultType = OperationResultType.NotImplemented;
            message = message.IsMissing() ? I18N.T(resultType.ToDescription()) : message;
            return new OperationResult() { ResultType = resultType, Message = message, Data = data };
        }
        #endregion
        #region "指定类型的未实现操作结果"
        /// <summary>
        /// 指定类型的未实现操作结果
        /// </summary>
        /// <typeparam name="T">操作结果数据类型</typeparam>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult<T> NotImplemented<T>(string message = null)
        {
            return NotImplemented<T>(default, message);
        }
        #endregion
        #region "指定类型的未实现操作结果"
        /// <summary>
        /// 指定类型的未实现操作结果
        /// </summary>
        /// <typeparam name="T">操作结果数据类型</typeparam>
        /// <param name="data">业务操作结果数据</param>
        /// <param name="message">业务操作结果消息</param>
        /// <returns>业务操作结果</returns>
        public static OperationResult<T> NotImplemented<T>(T data, string message = null)
        {
            var resultType = OperationResultType.NotImplemented;
            message = message.IsMissing() ? I18N.T(resultType.ToDescription()) : message;
            return new OperationResult<T>() { ResultType = resultType, Message = message, Data = data };
        }
        #endregion

        #endregion

    }

    /// <summary>
    /// 指定结果数据类型的业务操作结果
    /// </summary>
    /// <typeparam name="TData">结果数据的类型</typeparam>
    public class OperationResult<TData> : ResultBase<OperationResultType, TData>
    {
        #region "属性"
        #region "获取或设置 返回消息"
        /// <summary>
        /// 获取或设置 返回消息
        /// </summary>
        public override string Message
        {
            get { return _message ?? ResultType.ToDescription(); }
            set { _message = value; }
        }
        #endregion

        #region "获取 是否成功"
        /// <summary>
        /// 获取 是否成功
        /// </summary>
        public bool Succeeded => ResultType == OperationResultType.Success;
        #endregion
        #region "获取 是否失败"
        /// <summary>
        /// 获取 是否失败
        /// </summary>
        public bool Failed
        {
            get
            {
                bool contains = new[] {
                    OperationResultType.Error,
                    OperationResultType.Unauthorized,
                    OperationResultType.Forbidden,
                    OperationResultType.NotFound,
                    OperationResultType.NotAllowed,
                    OperationResultType.Unsupported,
                    OperationResultType.Locked,
                    OperationResultType.InternalError,
                    OperationResultType.NotImplemented,
                }.Contains(ResultType);
                return contains;
            }
        }
        #endregion

        #endregion

        #region "构造函数"
        #region "初始化一个指定结果数据类型的业务操作结果的新实例"
        /// <summary>
        /// 初始化一个指定结果数据类型的业务操作结果 <see cref="OperationResult{TData}"/> 的新实例
        /// </summary>
        public OperationResult()
            : this(OperationResultType.Success)
        { }
        #endregion
        #region "初始化一个指定结果数据类型的业务操作结果的新实例"
        /// <summary>
        /// 初始化一个指定结果数据类型的业务操作结果 <see cref="OperationResult{TData}"/> 的新实例
        /// </summary>
        /// <param name="resultType">业务操作结果</param>
        public OperationResult(OperationResultType resultType)
            : this(resultType, null, default)
        { }
        #endregion
        #region "初始化一个指定结果数据类型的业务操作结果的新实例"
        /// <summary>
        /// 初始化一个指定结果数据类型的业务操作结果 <see cref="OperationResult{TData}"/> 的新实例
        /// </summary>
        /// <param name="resultType">业务操作结果</param>
        /// <param name="message">业务操作结果消息</param>
        public OperationResult(OperationResultType resultType, string message)
            : this(resultType, message, default)
        { }
        #endregion
        #region "初始化一个指定结果数据类型的业务操作结果的新实例"
        /// <summary>
        /// 初始化一个指定结果数据类型的业务操作结果 <see cref="OperationResult{TData}"/> 的新实例
        /// </summary>
        /// <param name="resultType">业务操作结果</param>
        /// <param name="message">业务操作结果消息</param>
        /// <param name="data">业务操作结果数据</param>
        public OperationResult(OperationResultType resultType, string message, TData data)
            : base(resultType, message, data)
        { }
        #endregion

        #endregion

        #region "方法"
        #region "将<see cref="OperationResult{TData}"/>转换为<see cref="OperationResult"/>"
        /// <summary>
        /// 将<see cref="OperationResult{TData}"/>转换为<see cref="OperationResult"/>
        /// </summary>
        /// <returns></returns>
        public OperationResult ToOperationResult()
        {
            return new OperationResult() { ResultType = ResultType, Message = Message, Data = Data };
        }
        #endregion
        #region "将<see cref="OperationResult{TData}"/>转换为指定类型<see cref="OperationResult{TData2}"/>"
        /// <summary>
        /// 将<see cref="OperationResult{TData}"/>转换为指定类型<see cref="OperationResult{TData2}"/>
        /// </summary>
        /// <typeparam name="TData2"></typeparam>
        /// <param name="data"></param>
        /// <returns></returns>
        public OperationResult<TData2> ToOperationResult<TData2>(TData2 data = default)
        {
            return new OperationResult<TData2>() { ResultType = ResultType, Message = Message, Data = data };
        }
        #endregion

        #endregion

    }

}
